import { request } from '@umijs/max';
import { stringify } from 'qs';

//登录
export const login = (params: API.UserLogin) =>
  request<API.UserInfo>('/sysUser/login', {
    method: 'POST',
    data: params,
  });
//注册
export const register = (params: API.UserLogin) =>
request('/sysUser/register', {
  method: 'POST',
  data: params,
});
//登出
export const logout = () =>
  request(`/sysUser/logout`, {
    method: 'POST',
  });

  
//搜索用户By nickname
export const searchUser = (params:{
  current: number;
  size: number;
  value: string;
}) =>
  request(`/sysUser/search?${stringify(params)}`, {
    method: 'GET',
  });





//修改用户个人信息
export const editUserInfo = (params:{
/**
     * 头像
     */
avatar?: null | string;
/**
 * 用户ID
 */
id?: number | null;
/**
 * 用户昵称
 */
nickname?: null | string;
/**
 * 密码
 */
password?: null | string;
/**
 * 角色:（ADMIN、USER）
 */
role?: null | string;
/**
 * 账号状态：1启用，0停用
 */
status?: number | null;
/**
 * 用户名
 */
username?: null | string;
}) =>request(`/sysUser/update`,{
  method:'PUT',
  data:params
})


//获取关注列表
export const getFollowList = () =>request(`/follow/new-follow`)

//关注
export const followUserByUserId = (userId:string) =>request(`/follow/add/${userId}`,{
  method:'POST'
})

//取消关注
export const cancelFollowByUserId = (userId:string) =>request(`/follow/del/${userId}`,{
  method:'DELETE'
})

